package
{
	import flash.display.Sprite;
	import flash.utils.ByteArray;
	
	public class TestJson extends Sprite
	{
		public function TestJson()
		{
			var testObj:Object = {}
			testObj.smallInt = 15
			testObj.medInt = 120700
			testObj.bigInt = 10900800700
			testObj.doubleVal = Math.PI
			testObj.muppetNames = ["Kermit", "Fozzy", "Piggy", "Animal", "Gonzo"]
			testObj.fruits = [
				{name:"Apple", color:"red", inStock:true, price:1.50},
				{name:"Lemon", color:"yellow", inStock:false, price:0.80},
				{name:"Apricoat", color:"orange", inStock:true, price:1.90},
				{name:"Kiwi", color:"green", inStock:true, price:2.30}
			];
			
			
			var jsonStr:String = JSON.stringify(testObj);
			trace(jsonStr);
			
			var jsonB:ByteArray = new ByteArray();
			jsonB.writeUTF(jsonStr);
			
			var jsonObj:Object = JSON.parse(jsonStr);
			trace(jsonObj.toString());
			
			var objB:ByteArray = new ByteArray();
			objB.writeObject(testObj);
			
			trace(jsonB.length,objB.length);
		}
	}
}